package java_0530_map;

import java.util.Comparator;
import java.util.TreeMap;

@SuppressWarnings({"all"})
public class TreeMap01 {
    public static void main(String[] args) {
        TreeMap treeMap = new TreeMap(new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                return ((String) o1).length() - ((String) o2).length();

            }
        });


        treeMap.put("a", "1");
        treeMap.put("ab", "1");
        treeMap.put("abc", "1");
        treeMap.put("a", "2");
        System.out.println("treeMap"+treeMap);

        /*
        cmp = cpr.compare(key, t.key);
                if (cmp < 0)
                    t = t.left;
                else if (cmp > 0)
                    t = t.right;
                else {//如果compare结果一样，就进行value的替换，
                    V oldValue = t.value;
                    if (replaceOld || oldValue == null) {
                        t.value = value;
                    }
                    return oldValue;
                }
         */
    }
}
